package com.topcoder.srm520;

public class SRMCodingPhase {
	public int countScore(int[] points, int[] skills, int luck) {
		int best = 0;
		for (int x=0; x<2; x++) {
			for (int y=0; y<2; y++) {
				for (int z=0; z<2; z++) {
					int time = x*skills[2] + y*skills[1] + z*skills[0] - luck;
					if (time > 75) continue;
					int score = 0;
					int l = luck;
					int use = 0;
					if (x > 0) {
						use = Math.min(l, skills[2] - 1);
						l -= use;
						score += points[2] - 8*skills[2] + 8*use;
					}
					if (y > 0) {
						use = Math.min(l, skills[1] - 1);
						l -= use;
						score += points[1] - 4*skills[1] + 4*use;
					}
					if (z > 0) {
						use = Math.min(l, skills[0] - 1);
						score += points[0] - 2*skills[0] + 2*use;
					}
					
					if (score > best) best = score;
				}
			}
		}
		return best;
	}
}
